﻿namespace NumeralSystems
{
    using System;

    public class ConvertRandomBinaryToDecimal
    {
        // 1.1.8.05. Write a program that converts a binary number to decimal one.
       
        public static int CalculatePower(int num, int power)
        {
            int result = 1;
            for (int i = 0; i < power; i++)
            {
                result *= num;
            }

            return result;
        }

        public static int ConvertBinaryToDecimal(string binaryNum)
        {
            int numAsDecimal = 0;
            for (int i = 0; i < binaryNum.Length; i++)
            {
                if (binaryNum[binaryNum.Length - 1 - i] == '1')
                {
                    numAsDecimal += 1 * CalculatePower(2, i);
                }
            }
            
            return numAsDecimal;
        }

        static void Main()
        {
            string binaryNum = Console.ReadLine();
            Console.WriteLine(ConvertBinaryToDecimal(binaryNum));
        }
    }
}